import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    component: () =>import('../views/login/index.vue')
  },
  {
    path: '/home',
    component:()=>import('../components/home.vue'),
    children:[
      {
        path: '/dashboard',
        component:()=>import('../views/describe/dashboard.vue')
      },
      {
        path: '/addshop',
        component:()=>import('../views/describe/addshop.vue')
      }
    ]
  },
  {
    path:'/user',
    component:()=>import('../components/home.vue'),
    children:[
      {
        path:'message',
        name:'message',
        component:()=>import('../views/user/message.vue')
      },
      {
        path:'fixmessage',
        name:'fixmessage',
        component:()=>import('../views/user/fixmessage.vue')
      }
    ],
  },
  {
    path:'/configure',
    component:()=>import('../components/home.vue'),
    children:[
      {
        path:'lunbo',
        name:'conlb',
        component:()=>import('../views/configure/lunbo.vue')
      },
      {
        path:"rootshop",
        name:'shopnew',
        component:()=>import('../views/configure/rootshop.vue')
      },
      {
        path:"tuijian",
        name:'tjshangping',
        component:()=>import('../views/configure/tuijian.vue')
      },
      {
        path:'xinpin',
        name:'newxin',
        component:()=>import('../views/configure/xinpin.vue')
      }
    ],
  },
  {
    path:'/modular',
    component:()=>import('../components/home.vue'),
    children:[
      {
        path:'classification',
        name:'classfication',
        component:()=>import('../views/modular/classification.vue')
      },
      {
        path:'dingdan',
        name:'Ddan',
        component:()=>import('../views/modular/dingdan.vue')
      },
      {
        path:'hotguan',
        name:'huiyuan',
        component:()=>import('../views/modular/hotguan.vue')
      },
      {
        path:'shopguan',
        name:'shangpin',
        component:()=>import('../views/modular/shopguan.vue')
      }
    ]
  }
]
const router = createRouter({
  history: createWebHistory(),
  routes,
})

// router.beforeEach((to, from, next) => {
//   //NProgress.start();
//   if (to.path == '/login') {
//     sessionStorage.removeItem('user');
//   }
//   let user = JSON.parse(sessionStorage.getItem('user'));
//   if (!user && to.path != '/login') {
//     next({ path: '/login' })
//   } else {
//     next()
//   }
// })

export default router
